
var mivaUtils = {
  baseUri: 'http://lah.wangmengyun.com/index.php',
  getBookId: function(param) {
    var num = param.indexOf('=')
    var id = param.substring(num+1)
    if (id.indexOf('&') > -1) {
      id = id.slice(0, id.indexOf('&'))
    }
    return id;
  },
  checkLogin: function(url) {
    const token = localStorage.getItem('token');

    if (!token) {
      mui.toast('请先登录!');

      url.indexOf('pages/') > -1
      ? url = 'pages/loginPage.html'
      : url = './loginPage.html';

    }

    return url;
  },
  settingHeight: function() {
    // android沉浸导航的高度设置
    mui.plusReady(function (){
      var padding = 'padding-top: ' + plus.navigator.getStatusbarHeight()+'px';
      if (mui.os.android) {
        if (plus.navigator.isImmersedStatusbar()) {
          document.querySelector('.mui-bar').style = 'height:' + (plus.navigator.getStatusbarHeight() + 44) + 'px' + padding;
          document.querySelector('.mui-content').style = padding;
        }
      }
    })
  },
};
